package com.hsgene.order.dto.console;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.hsgene.common.util.qiniu.QiniuListResourcesSerializer;
import com.hsgene.common.util.validation.FieldChecker;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;

/**
 * 订单退款信息
 *
 * @author wangbing
 * @version 1.0
 * @date 2019/1/17 15:26
 * Copyright: Copyright (c) 2019
 */
public class OrderRefundInfoDto implements Serializable {

    private static final long serialVersionUID = -8746092931016452266L;
    /**
     * 订单id
     */
    private String orderId;

    /**
     * 订单编号
     */
    private String orderNo;

    /**
     * 退款原因
     */
    private String refundReason;

    /**
     * 退款总金额
     */
    private BigDecimal totalRefundAmount;

    /**
     * 退款凭证
     */
    @JsonSerialize(using = QiniuListResourcesSerializer.class)
    private List<String> refundVouchers;

    /**
     * 退款套餐信息
     */
    private List<OrderRefundPackageDto> refundPackages;

    /**
     * 订单退款字段检查
     */
    public void checkRefund() {
        FieldChecker.checkEmpty(orderId, "订单id");
        FieldChecker.checkMaxLength(refundReason, 300, "退款原因");
        FieldChecker.checkMaxSize(refundVouchers, 5, "退款凭证", "图片张数");
        FieldChecker.checkEmpty(refundPackages, "退款套餐信息");
        refundPackages.forEach(OrderRefundPackageDto::check);
    }

    public String getOrderId() {
        return orderId;
    }

    public void setOrderId(String orderId) {
        this.orderId = orderId;
    }

    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public String getRefundReason() {
        return refundReason;
    }

    public void setRefundReason(String refundReason) {
        this.refundReason = refundReason;
    }

    public BigDecimal getTotalRefundAmount() {
        return totalRefundAmount;
    }

    public void setTotalRefundAmount(BigDecimal totalRefundAmount) {
        this.totalRefundAmount = totalRefundAmount;
    }

    public List<String> getRefundVouchers() {
        return refundVouchers;
    }

    public void setRefundVouchers(List<String> refundVouchers) {
        this.refundVouchers = refundVouchers;
    }

    public List<OrderRefundPackageDto> getRefundPackages() {
        return refundPackages;
    }

    public void setRefundPackages(List<OrderRefundPackageDto> refundPackages) {
        this.refundPackages = refundPackages;
    }
}
